#!/usr/bin/ruby
# ggpvision build files generator by gogoprog @ gmail . com


def analyze( line )

    current_dir = ""
    path = ""
    line.each_char { |c|
        if c != '/' then            
            current_dir += c
        else
            path = current_dir
            current_dir += "_"
        end
    }

    path = "build_" + path + ".cpp"

    code_line = "'\#include \"../" + line + "\"'"
    cmd_line = "echo " + code_line + " >> " + "./generated/" + path

    system( cmd_line )
        
end



# main
puts "Cleaning..."
system("rm -rf generated");

puts "Generating..."

system("mkdir generated")

Dir.glob("*/*.cpp") {|file|

    analyze( file )
}

Dir.glob("*/*/*.cpp") {|file|

    analyze( file )
}

puts "Done!"



